<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回当前线程的 ID</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.mysql-thread-id" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">mysql_thread_id</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">mysql_thread_id</span> &mdash; <span class="dc-title">返回当前线程的 ID</span></p>

   </div>
   <div class="refsect1 unknown-unknown-unknown-seealsr" id="refsect1-function.mysql-thread-id-unknown-unknown-unknown-seealsr">
    <h3 class="title">说明</h3>
    <div class="methodsynopsis dc-description">
     <span class="methodname"><strong>mysql_thread_id</strong></span>
      ([ <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code></span>
    ] ) : <span class="type">int</span></div>

    <p class="para rdfs-comment">
     <span class="function"><strong>mysql_thread_id()</strong></span>
     返回当前线程的
     ID。如果连接丢失了并用
     <span class="function"><a href="mysql_ping.html" class="function">mysql_ping()</a></span>
     重新连接上，线程 ID 会改变。这意味着不能取得线程的
     ID 后保存起来备用。当需要的时候再去获取之。
    </p>
    <p class="para">
     <div class="example" id="example-2171">
      <p><strong>Example #1 <span class="function"><strong>mysql_thread_id()</strong></span> 例子</strong></p>
      <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$link&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'localhost'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'mysql_user'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'mysql_password'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$thread_id&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mysql_thread_id</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$thread_id</span><span style="color: #007700">){<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf&nbsp;</span><span style="color: #007700">(</span><span style="color: #DD0000">"current&nbsp;thread&nbsp;id&nbsp;is&nbsp;%d\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$thread_id</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
      </div>

      <div class="example-contents"><p>
       以上例子将产生如下输出：
      </p></div>
      <div class="example-contents screen">
<div class="cdata"><pre>
current thread id is 73
</pre></div>
      </div>
     </div>
    </p>
    <p class="para">
     参见
     <span class="function"><a href="mysql_ping.html" class="function">mysql_ping()</a></span> 和
     <span class="function"><a href="mysql_list_processes.html" class="function">mysql_list_processes()</a></span>。
    </p>
   </div>

  </div></div></div></body></html>